package Client.serviceCenter.balance.impl;

import Client.serviceCenter.balance.LoadBalance;

import java.util.List;

// 轮询负载均衡器
public class RoundLoadBalance implements LoadBalance {

    // 记录当前选择的服务节点的索引，初始化为-1，表示还没有选择过服务节点
    private int choose = -1;

    @Override
    public String balance(List<String> addressList) {
        choose++;
        choose = choose % addressList.size();
        System.out.println("轮询负载均衡器选择的服务节点为：" + addressList.get(choose));
        return addressList.get(choose);
    }

    @Override
    public void addNode(String node) {

    }

    @Override
    public void removeNode(String node) {

    }
}
